@extends('admin.layouts.app')
@section('content')

                        <!-- Page-Title -->
                        <div class="row">
                            <div class="col-sm-12">
                                <h4 class="page-title">客户联系人管理</h4>
                                <ol class="breadcrumb">
                                    <li><a href="{{url('zadmin')}}">系统</a></li>
                                   
                                    <li class="active">客户联系人列表</li>
                                </ol>
                            </div>
                        </div>
                        
                        <div class="row">
                        	<div class="col-lg-12">
                        		<div class="card-box">
                        			<div class="row">
			                        	<div class="col-sm-8">
			                        		<form role="form">
			                                    <div class="form-group contact-search col-sm-8">
			                                    	<input type="text" id="search" class="form-control" placeholder="Search..." name="keyword" value="{{array_get($where,'keyword')}}">
                                          </div>
                                          <div class="col-sm-4">
			                                        <button type="submit" class="btn btn-white"><i class="fa fa-search"></i></button>
			                                    </div> <!-- form-group -->
			                                </form>
			                        	</div>
			                        	<div class="col-sm-4">
			                        		

                                  <button type="button" class="btn btn-primary" id="btnAddModal" ><i class="md md-add"></i>添加</a>
			                        	</div>
			                        </div>

                              @if(session('rs'))
                              <div class="alert alert-{{session('rs')['status']}}">
                                {{ session('rs')['msg'] }}
                              </div>
                              @endif
			                        
                        			<div class="table-responsive">
                                        <table class="table table-hover">
                                        	<thead>
												<tr>
													<th style="min-width: 35px;">
													ID
                                                        
													</th>
													
													<th>姓名</th>
                          <th>电话</th>
                          <th>所属客户</th>
                         
                         
                         
													<th style="width: 200px;">操作</th>
												</tr>
											</thead>
											
                                            <tbody>

                                            @foreach($list as $v)
                                                <tr>
                                                    <td>
                                                        {{$v->id}}
                                                        
                                                      
                                                    </td>
                                                    
                                                    
                                                   <td>{{$v->name}}</td> 
                                                   <td>{{$v->phone}}</td>
                                                  
                                                   <td>
                                      {{object_get($v,'client.name')}}
                                                   </td>    
                                                
                                                    
                                                   
                                                    <td>
                                                    	<a href="{{url('zadmin/client-users/'.$v->id.'/edit')}}" ><i class="md md-edit"></i>编辑</a>
                                                    	<a href="{{url('zadmin/client-users',$v->id)}}" data-method="delete" 
  data-token="{{csrf_token()}}" data-confirm="确定删除吗?"><i class="md md-close"></i>删除</a>
                                                    </td>
                                                </tr>
                                            @endforeach    
                                                
                                               
                                               
                                                
                                               
                                                
                                            
                                            </tbody>
                                        </table>
                                    </div>
                        		</div>
                                
                            </div> <!-- end col -->

                            
                        </div>
@endsection
                        
                        
                        

                  
            
    @section('modal')        
        <!-- Modal -->
  <div class="modal fade" id="custom-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
           <form class="form-horizontal" role="form" action="{{url('zadmin/client-users')}}" method="post" enctype="multipart/form-data">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">添加客户联系人</h4>
            </div>
            <div class="modal-body">
              <div class="form-group">
                    <label class="col-md-2 control-label">所属客户</label>
                    <div class="col-md-10">
                      <select name="client_id" class="form-control select2">
                      <option value="">请选择</option>                   
                      @foreach($clients as $client)
                        <option value="{{$client->id}}" {{$client->id==array_get($where,'client_id')?'selected':''}}>{{$client->name}}</option>
                      @endforeach
                      </select>  
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">微信用户</label>
                    <div class="col-md-10">
                      <select name="openid" class="form-control select2">
                      <option value="">请选择</option>                   
                      @foreach($wxusers as $wxuser)
                        <option value="{{$wxuser->openid}}">{{$wxuser->nickname}}</option>
                      @endforeach
                      </select>  
                    </div>
                </div>

                                              <div class="form-group">
                                                  <label class="col-md-2 control-label">姓名</label>
                                                  <div class="col-md-10">
                                                      <input type="text" class="form-control" name="name" value="" required="">
                                                  </div>
                                              </div>
                                              <div class="form-group">
                                                  <label class="col-md-2 control-label">电话</label>
                                                  <div class="col-md-10">
                                                      <input type="text" class="form-control" name="phone" value="" required="">
                                                  </div>
                                              </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="submit" class="btn btn-primary">提交</button>
            </div>
            {{csrf_field()}}
          </form>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
      
    @endsection  

    @section('js')
    <script type="text/javascript">
      $(document).ready(function() {  
        $('#btnAddModal').on('click',function(){
          $("#custom-modal").modal('show');
        });

        $(".select2").select2({
            dropdownParent:$("#custom-modal"),
            width:200
        });
     });
    </script>
   
    @endsection      
       

           



    
        
    
